<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>ztree树菜单和tabs空间的结合</title>
		<script type="text/javascript" src="../js/jquery-1.8.3.js"></script>
		<script type="text/javascript" src="../js/easyui/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../js/easyui/locale/easyui-lang-zh_CN.js"></script>
		<link rel="stylesheet" href="../js/easyui/themes/default/easyui.css" />
		<link rel="stylesheet" href="../js/easyui/themes/icon.css" />
		
		<!--首先引入ztree的样式和js文件-->
		<script type="text/javascript" src="../js/ztree/jquery.ztree.all-3.5.js"></script>
		<link rel="stylesheet" href="../js/ztree/zTreeStyle.css"/>
		<script type="text/javascript">
			$(function(){
				//1,进行ztree菜单设置
				var setting = {
					data:{
						simpleData:{
							enable:true,
						}
					},
					callback:{
						onClick:function(event,treeId,treeNode,clickFlag){
							alert(treeNode.page);
							var content = '<div style="width:100%;height:100%;overflow:hidden;">'
								+ '<iframe src="'
								+ treeNode.page
								+ '" scrolling="auto" style="width:100%;height:100%;border:0;" ></iframe></div>';
							
							
							//没有page的属性菜单，不打开选项卡。
							if(treeNode.page){
								//如果打开了，那么我们就需要选中
								if($("#tt").tabs('exists',treeNode.name)){
									//选中选项卡的代码
									$("#tt").tabs('select',treeNode.name);
								}else{
									//没有的话，那么我们就使用代码创建一个easyui的选项卡控件
									$("#tt").tabs('add',{
										title:treeNode.name,
										closable:true,
										content:content
									});
								}
							}
							
						}
					}
				};
				//2,提供树形菜单的数据
				var zNodes = [
					{id:1,pId:0,name:'父节点1'},
					{id:2,pId:0,name:'父节点2'},
					{id:3,pId:1,name:'百度',page:'http://www.baidu.com'},
					{id:4,pId:1,name:'京东',page:'http://www.jd.com'},
					{id:5,pId:2,name:'雅虎',page:'http://www.yahoo.com'},
					{id:6,pId:2,name:'搜狐',page:'http://www.sohu.com'}
				];
				//3，生成菜单
				$.fn.zTree.init($("#base"), setting, zNodes);
	
			});
		</script>
	</head>

	<body class="easyui-layout">

		<div data-options="region:'north',title:'North Title',split:true" style="height:100px;"></div>
		<div data-options="region:'south',title:'South Title',split:true" style="height:100px;"></div>
		<div data-options="region:'east',iconCls:'icon-reload',title:'East',split:true" style="width:100px;"></div>
		<div data-options="region:'west',title:'West',split:true" style="width:180px;">
			<!--折叠面板 -->
			<div class="easyui-accordion" data-options="fit:true">
				<div data-options="title:'基础菜单'">
					<!--在手风琴模式里面进行数据的设置，树模式一般都是依赖于ul标签的-->
					<ul id="base" class="ztree"></ul>
				</div>
				<div data-options="title:'系统菜单',selected:true">
					当前不允许系统操作
				</div>
			</div>
		</div>
		<div data-options="region:'center',title:'center title'" style="padding:5px;background:#eee;">
			<div id="tt" class="easyui-tabs" data-options="fit:true">
				<div title="Tab1">
					tab1
				</div>
				<div title="Tab2" data-options="closable:true">
					tab2
				</div>
				<div title="Tab3" data-options="iconCls:'icon-reload',closable:true">
					tab3
				</div>
			</div>
		</div>
	</body>

</html>